home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-01-04 | 2.1 KB | 93 lines | [TEXT/nX^n] |
- Global Procedures for MTPB
- © MacTutor Magazine, February 1991
-
- f_format_number
- `Pretty-process a phone number
- `Examples:
- `format_number("3131234567")->(313)123-4567
- `format_number("3131234567";"313")->123-4567
- `Arguments:$1 = raw phone number
- ` $2 = area code to drop, if any.
- `Return Value: $0 = formatted result.
- If (Length($1)>0)
- If (Length($2)=3)
- `The caller wants to zap an area code...
- If (Substring($1;1;3)=$2)
- `Omit the area code
- $0:=Substring($1;4;3)+ "-" +
- Substring($1;7;4)
- Else
- `Keep it
- $0:="("+Substring($1;1;3)+") " +
- Substring($1;4;3) + "-" +
- Substring($1;7;4)
- End if
- Else
- `Caller wants the area code no matter what
- $0:="(" + Substring($1;1;3)+")" +
- Substring($1;4;3) + "-" +
- Substring($1;7;4)
- End if
- End if
-
- p_display
- `Display all records in the phone book
- DEFAULT FILE([Phone Book])
- ALL RECORDS
- OUTPUT LAYOUT([Phone Book];"Output Layout")
- MODIFY SELECTION
-
- p_print_sel
- `Print the records last selected by the user
- DEFAULT FILE([Phone Book])
- If (Records in selection=0)
- ALERT("You haven't selected any records
- to print!")
- Else
- OUTPUT LAYOUT([Phone Book];"Output Layout")
- PRINT SELECTION([Phone Book])
- End if
-
- p_print_tbl
- `Print all records in the phone book
- DEFAULT FILE([Phone Book])
- ALL RECORDS
- OUTPUT LAYOUT([Phone Book];"Output Layout")
- PRINT SELECTION([Phone Book])
-
- p_search
- `Let the user perform a search on the database
- DEFAULT FILE([Phone Book])
- SEARCH
- If (OK=1)
- OUTPUT LAYOUT([Phone Book];"Output Layout")
- DISPLAY SELECTION
- End if
-
- p_sort
- `Permanently sort the database, and display
- `results to the user.
- DEFAULT FILE([Phone Book])
- OPEN WINDOW(110;100;390;260;0;"Sort The Database")
- DIALOG("Sort Dialog")
- `Note: the actual sorting takes place in the script
- ` associated with the "ok" button, but is
- ` omitted here for brevity.
- CLOSE WINDOW
- If (g_display=True)
- p_display
- End if
-
- p_labels
- DEFAULT FILE([Phone Book])
- ALL RECORDS
- PRINT LABEL([Phone Book];" ")
-
- p_new
- `Add new records(s) until the user cancels
- DEFAULT FILE([Phone Book])
- INPUT LAYOUT([Phone Book];"Input Layout")
- Repeat
- ADD RECORD
- Until (OK=0)
-